// [!HeaderName] : Declaration of the [!ClassName]

[!crlf]

#ifndef __[!UpperShortName]_H_
#define __[!UpperShortName]_H_
[!crlf]

[!if=(ScoringComponent,"TRUE")]
// NOTE: You will need msado15.h/adoint.h from the platform SDK to build CSF components
[!crlf]
[!endif]
[!if=(CacheLoader,"TRUE")]
// NOTE: You will need msado15.h/adoint.h from the platform SDK to build CSF components
[!crlf]
[!endif]

#include "resource.h"       // main symbols
#include "computil.h"
#include "pipeline.h"
#include "pipecomp.h"
#include "pipe_stages.h"
[!if=(ScoringComponent,"TRUE")]
#include "cl_schema.h"
[!endif]
[!if=(CacheLoader,"TRUE")]
#include "cacheint.h"
[!endif]
[!if=(IObjectControl,"TRUE")]
#include "mtx.h"
[!endif]
[!crlf]
#define PIPECOMP_STATUS_OK   0
#define PIPECOMP_STATUS_WARN 1
#define PIPECOMP_STATUS_FAIL 2
[!crlf]

/////////////////////////////////////////////////////////////////////////////
// [!ClassName]
class ATL_NO_VTABLE [!ClassName] : 
	public CComObjectRootEx<CComMultiThreadModel>,
	public CComCoClass<[!ClassName], &CLSID_[!CoClassName]>,
	public ISupportErrorInfo,
[!if=(IPersistStreamInit, "TRUE")]
	public IPersistStreamInit,
[!endif]
	public IPipelineComponent,
[!if=(IPipelineComponentDescription, "TRUE")]
	public IDispatchImpl<IPipelineComponentDescription, &IID_IPipelineComponentDescription, &LIBID_[!LibName]>,
[!endif]
[!if=(IPipelineComponentAdmin, "TRUE")]
	public IDispatchImpl<IPipelineComponentAdmin, &IID_IPipelineComponentAdmin, &LIBID_[!LibName]>,
[!endif]
[!if=(ISpecifyPropertyPages, "TRUE")]
	public ISpecifyPropertyPages,
[!endif]
[!if=(IObjectControl,"TRUE")]
	public IObjectControl,
[!endif]
	public IDispatchImpl<[!InterfaceName], &IID_[!InterfaceName], &LIBID_[!LibName]>
{
public:
	[!ClassName]() [!if=(IPersistStreamInit, "TRUE")] : m_lStreamVersionMajor(0),
		  m_lStreamVersionMinor(0) 
	[!endif]
	{
		[!if=(ScoringComponent, "TRUE")] m_bCLSchemaDiscovered = FALSE; [!endif]
	}

[!crlf]
BEGIN_COM_MAP([!ClassName])
	COM_INTERFACE_ENTRY([!InterfaceName])
	COM_INTERFACE_ENTRY2(IDispatch, [!InterfaceName])
	COM_INTERFACE_ENTRY(IPipelineComponent)
[!if=(IPipelineComponentDescription, "TRUE")]
	COM_INTERFACE_ENTRY(IPipelineComponentDescription)
[!endif]
[!if=(IPipelineComponentAdmin, "TRUE")]
	COM_INTERFACE_ENTRY(IPipelineComponentAdmin)
[!endif]
[!if=(IPersistStreamInit, "TRUE")]
	COM_INTERFACE_ENTRY(IPersistStreamInit)
[!endif]
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
[!if=(ISpecifyPropertyPages, "TRUE")]
	COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
[!endif]
[!if=(IObjectControl,"TRUE")]
	COM_INTERFACE_ENTRY(IObjectControl)
[!endif]
END_COM_MAP()

// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

// [!InterfaceName]
public:

[!if=(IPersistStreamInit, "TRUE")]
// IPersistStreamInit
    const long  m_lStreamVersionMajor;   // major version number of the stream
    const long  m_lStreamVersionMinor;   // minor version number of the stream

    STDMETHOD(GetClassID)(CLSID *pClassID);
    STDMETHOD(IsDirty)(void);
    STDMETHOD(Load)(IStream *pStm);
    STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty);
    STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize);
    STDMETHOD(InitNew)(void);
[!crlf]
[!endif]

// IPipelineComponent
	STDMETHOD(Execute)(
				IDispatch*  pdispOrder,
				IDispatch*  pdispContext,
				LONG        lFlags,
				LONG*       plErrorLevel);

	STDMETHOD (EnableDesign) (BOOL fEnable);
[!crlf]
[!if=(ISpecifyPropertyPages, "TRUE")]
// ISpecifyPropertyPages
	STDMETHOD (GetPages)(CAUUID *pPages);
[!crlf]
[!endif]


[!if=(IPipelineComponentDescription, "TRUE")]
// IPipelineComponentDescription
	STDMETHOD(ContextValuesRead)(VARIANT *pVarRead);
	STDMETHOD(ValuesRead)(VARIANT *pVarRead);
	STDMETHOD(ValuesWritten)(VARIANT *pVarWritten);
[!crlf]
[!endif]

[!if!(CacheLoader)]
	static HRESULT WINAPI UpdateRegistry(BOOL bRegister)
	{
		HRESULT hr = _Module.UpdateRegistryFromResource([!IDR_REGISTRYID], bRegister);
		if (SUCCEEDED(hr))
		{
[!if!(ScoringComponent)] 
			// TODO: Add stage affinities here 
[!endif]
			hr = RegisterCATID(GetObjectCLSID(), CATID_MSCSPIPELINE_COMPONENT);
[!if=(ScoringComponent,"TRUE")]
            hr = RegisterCATID(GetObjectCLSID(), CATID_MSCSPIPELINE_CSF_INITIAL);
[!else]
			hr = RegisterCATID(GetObjectCLSID(), CATID_MSCSPIPELINE_ANYSTAGE);
[!endif]
		}

		return hr;
	};
[!else]
DECLARE_REGISTRY_RESOURCEID([!IDR_REGISTRYID]);
[!endif]
[!crlf]
[!if=(Shipping,"TRUE")]
protected:
	HRESULT QueryForSimpleList(IDictionary *pdictParent, const WCHAR *pcszwName, ISimpleList **pslChild);
	HRESULT QueryForBSTR(IDictionary *pdictParent, const WCHAR *pcszwName, BSTR *bstrReturnVal);
	HRESULT QueryForDictionary(IDictionary * pdictParent, const WCHAR *pcszwName, IDictionary **pdictChild);
[!crlf]
[!endif]
[!if=(CacheLoader, "TRUE")]
protected:
	HRESULT UpdateVDir(_ADOConnection *pConn, IDictionary *pdictOrder);
	HRESULT LoadLargeString(CComBSTR &bstrToLoad, UINT unID);
	HRESULT CreateFactoryFromQuery(_ADOConnection *pConn, CComBSTR bstrTempTable, IContentListFactory** ppclfFactory);
	CComBSTR GetGUIDForTableName();
	CComBSTR m_bstrConnStr;
[!crlf]
[!endif]
[!if=(ScoringComponent,"TRUE")]
//  Scoring component custom elements.
protected:
    BOOL    m_bCLSchemaDiscovered;      // set to true once schema is successfully read
    ULONG   m_icolHeadlineDate;         // column ordinal for "headline_date"
    ULONG   m_icolHeadlinePriority;     // column ordinal for "headline_priority"

public:
    BEGIN_CL_SCHEMA_MAP
        CL_SCHEMA_ENTRY(L"headline_date", m_icolHeadlineDate, CLCOL_DATE)
        CL_SCHEMA_ENTRY(L"headline_priority", m_icolHeadlinePriority, CLCOL_I2)
    END_CL_SCHEMA_MAP
[!crlf]
[!endif]
[!if=(IPipelineComponentAdmin,"TRUE")]
// IPipelineComponentAdmin
public:
	STDMETHOD(GetConfigData)(IDispatch * * ppDict);
	STDMETHOD(SetConfigData)(IDispatch * pDict);
[!crlf]
[!endif]
[!if=(IObjectControl,"TRUE")]
// IObjectControl
public:
	STDMETHOD(Activate)();
	STDMETHOD_(VOID, Deactivate)();
	STDMETHOD_(BOOL, CanBePooled)();
[!crlf]
[!endif]

};

[!crlf]
#endif //__[!UpperShortName]_H_
